#include "Olor.h"
#include "CApp.h"

#include <SDL/SDL.h>
#include <SDL/SDL_gfxPrimitives.h>

Olor::Olor(float x, float y,
    long durarion, float w, float h){
  position[0] = x;
  position[1] = y;
  this->w = w;
  this->h = h;
  this->duration = durarion;
  oldTime = SDL_GetTicks();
  propagation = 150;
  oldTimeProp = 0;
}

void Olor::OnLoop(){
  // Por ahora nada, pero aqui se movera la posicion
  // de lap particula de olor
}

bool Olor::hasExpired(){
  long current = SDL_GetTicks();
  bool resp = false;
  if(current-oldTime>duration){
    resp = true;
  }
  return resp;
}

void Olor::OnRender(SDL_Surface* display){
  long current = SDL_GetTicks();
  int alpha = (1-(current - oldTime)/(float)duration)*45;
  filledEllipseRGBA(display,
    fixX(position[0]), fixY(position[1]),
    w, h,
    240, 160, 0, alpha
    );
}
